#!/bin/bash
# 自动生成的异常扫描脚本 - 2025-08-11T22:16:20.052576
# 适用于银河麒麟系统的Apache异常检测

LOG_PATHS=(
    "/var/log/httpd/access_log"
    "/var/log/httpd/error_log"
    "/var/log/messages"
)

echo "开始异常模式扫描: $(date)"
echo "扫描日志文件: ${LOG_PATHS[@]}" 

# 检测404扫描行为
echo -e "\n[检测] 短时间内大量404错误"
for log in "${LOG_PATHS[@]}"; do
    if [ -f "$log" ]; then
        grep -E ""GET .+?" 404" "$log" | tail -n 1000 | wc -l
    fi
done

# 检测错误日志中的严重错误
echo -e "\n[检测] Apache严重错误"
for log in "${LOG_PATHS[@]}"; do
    if [ -f "$log" ]; then
        grep -E "Segmentation fault|Out of memory" "$log" | tail -n 20
    fi
done

echo -e "\n扫描完成: $(date)"
